{extend name="common/application" /}
{block name="title"}<title>搜索中心-政务搜索</title>{/block}
{block name="css"}
<link rel="stylesheet" type="text/css" href="_CSS_/reset.css">
<link rel="stylesheet" type="text/css" href="_CSS_/common.css">
<link rel="stylesheet" type="text/css" href="_CSS_/slide.css">
<link rel="stylesheet" type="text/css" href="_CSS_/search_work.css">
<link rel="stylesheet" type="text/css" href="_CSS_/scom.css"/>
<!--[if lt IE 9]>
<script src="http://www.ijquery.cn/js/html5shiv.js"></script>
<![endif]-->
{/block}


{block name="content"}
<!-- 主体内容 -->
<div class="main">
    <div class="mainBody normalBox clearfix" style="padding-top: 0px;">
        <div class="courses sectionArea normalBox" style="margin-top: 0px;">
            <!--搜索类别-->
            <div class="courseMenu">
                {include file="/common/course" /}
                <input type="hidden" id="value">
                <div class="serviceHeader">
                    <div class="serviceNavi fl">
                        <a class="sortType active" value="0" href="javascript:;">综合</a>
                        <a class="sortType" value="1" href="javascript:;">最新</a>
                        <a class="sortType" value="2" href="javascript:;">最热</a>
                    </div>
                    <div class="total fr">
                        <p class="mr20">共<span class="num" id="count"></span>条新闻</p>
                        <a class="prev" href="javascript:;">
                            <span class="icons icon-prev hide"></span>
                            <span class="icons icon-grey-prev"></span>
                        </a>
                        <p><span class="currentPage">1</span>/<span class="allPage"></span></p>
                        <a class="next" href="javascript:;">
                            <span class="icons icon-next"></span>
                            <span class="icons icon-grey-next hide"></span>
                        </a>
                    </div>
                </div>
                <!--查询不出数据-->
                <!--相关政务-->
                <div class="con-part government-part">
                    <div class="conBody">
                    </div>
                </div>
                <!--分页-->
                <div id="page">
                </div>
            </div>
        </div>
    </div>
</div>

{/block}
{block name="js"}
<!-- 脚本引入 -->
<script src="_P_/layer/layer.js"></script>
<script src="_JS_/jquery.SuperSlide.2.1.2.js"></script>
<script>
    $('#sel_6').addClass('selected');
    $("a.selectType").eq(0).on('click', function () {
        var keyword = decodeURI(window.location.href.split("?")[1]);
        window.location.href = "{:url('index/search/search_work')}?" + keyword;
    });
    $("a.selectType").eq(1).on('click', function () {
        var keyword = decodeURI(window.location.href.split("?")[1]);
        window.location.href = "{:url('index/search/search_trade')}?" + keyword;
    });
    $("a.selectType").eq(2).on('click', function () {
        var keyword = decodeURI(window.location.href.split("?")[1]);
        window.location.href = "{:url('index/search/search_store')}?" + keyword;
    });
    $("a.selectType").eq(3).on('click', function () {
        var keyword = decodeURI(window.location.href.split("?")[1]);
        window.location.href = "{:url('index/search/search_courses')}?" + keyword;
    });
    $("a.selectType").eq(4).on('click', function () {
        var keyword = decodeURI(window.location.href.split("?")[1]);
        window.location.href = "{:url('index/search/search_persons')}?" + keyword;
    });
    $("a.selectType").eq(5).on('click', function () {
        var keyword = decodeURI(window.location.href.split("?")[1]);
        window.location.href = "{:url('index/search/search_teachers')}?" + keyword;
    });
    $("a.selectType").eq(6).on('click', function () {
        var keyword = decodeURI(window.location.href.split("?")[1]);
        window.location.href = "{:url('index/search/search_government')}?" + keyword;
    });
    $(function () {
        var keyword = decodeURI(window.location.href.split("?")[1]);
		$("#keyword").val(keyword);
        if (keyword == 'undefined') {
            keyword = null;
        }
        postfile(1, keyword);
    });
   

    $('.prev').on('click', function () {
        var value = $("#value").val();
        var keyword = decodeURI(window.location.href.split("?")[1]);
        var prev_num = parseInt($('.currentPage').html()) - 1;
        if (prev_num != 0) {
            postfile(prev_num, keyword, value);
        }
    });
    $('.next').on('click', function () {
        var value = $("#value").val();
        var keyword = decodeURI(window.location.href.split("?")[1]);
        var next_num = parseInt($('.currentPage').html()) + 1;
        var max_num = parseInt($('.allPage').html());
        if (next_num <= max_num) {
            postfile(next_num, keyword, value);
        }
    });

    $(".sortType").on('click', function () {
        $('.sortType').removeClass('active');
        $(this).addClass('active');
        var value = $(this).attr('value');
        $("#value").val(value)
        var keyword = decodeURI(window.location.href.split("?")[1]);
        postfile(1, keyword, value);
    });

    function postfile(page, keyword, value) {
        $.ajax({
            type: 'get',
            url: "{:url('api/keyword/search_government')}",
            data: {'keyword': keyword, 'number': 5, 'page': page, 'value': value},
            dataType: 'jsonp',
            success: function (msg) {
                if (msg.code == 200) {
                    $('.num').html(msg.data.count);
                    $('.currentPage').html(page);
                    var pages = Math.ceil(msg.data.count / 5);
                    $('.allPage').html(pages);
                    $("#count").html(msg.data.count);
                    var government = "";//政务
                    //相关政务
                    if (msg.data.government.length != 0) {
                        for (var y = 0; y < msg.data.government.length; y++) {
                            var src = msg.data.government[y].pic;
                            government += '<div class="sectionItem"><div class="sectionImgbox fl">' +
                                '<img class="sectionImg" src="' + src + '"></div>' +
                                '<a class="sectionTitle text_overflow fl" href="/index.php/index' +
                                '/government/government_details.html?id=' + msg.data.government[y].id + '">' + msg.data.government[y].title + '</a>' +
                                '<p class="sectionSummary moreline fl" limit="90">' + msg.data.government[y].abstract + '</p><div class="sectionTags fl">' +
                                '<p class="time"><span class="icons icon-time"></span>' + getMyDate(msg.data.government[y].time * 1000) + '</p>' +
                                '<p class="view"><span class="icons icon-view"></span>' + msg.data.government[y].views + '</p>' +
                                '<p class="praise"><span class="icons icon-praise"></span>' + msg.data.government[y].likes + '</p>' +
                                '<p class="collect"><span class="icons icon-collect"></span>' + msg.data.government[y].collect + '</p></div></div>';
                        }
                        $(".conBody").html(government);
                        if (msg.data.government.length == 0) {
                            $('#page').html('');
                        } else {
                            $('#page').html(msg.data.render);
                            $("#pagination").delegate("a", "click", function () {
                                var value = $("#value").val();
                                var num = $(this).attr("num");
                                if (num) {
                                    postfile(num, keyword, value);
                                }
                            });
							$("#GO").on('click',function(){
								var king = $("#go").val();
								if(king > pages){
									layer.alert("最多输入"+pages+"页");
									return;
								}
								postfile(king, c_id, category, value);
							});
                        }
                    } else {
                        var personnel = '<div class="nodatas normalBox">' +
                            '<img src="/static/web/images/nodata.png"/>' +
                            '<p>抱歉，找不到相关数据</p></div>';

                        $(".conBody").html(personnel);
                    }
                }
            }
        })
    }
</script>
{/block}